;(function webpackUniversalModuleDefinition(root, factory) {
  if (typeof exports === 'object' && typeof module === 'object') module.exports = factory()
  else if (typeof define === 'function' && define.amd) define([], factory)
  else if (typeof exports === 'object') exports['kit'] = factory()
  else root['kit'] = factory()
})(this, function () {
  return (function (modules) {
    var installedModules = {}
    function __webpack_require__(moduleId) {
      if (installedModules[moduleId]) {
        return installedModules[moduleId].exports
      }
      var module = (installedModules[moduleId] = {
        i: moduleId,
        l: false,
        exports: {}
      })
      modules[moduleId].call(module.exports, module, module.exports, __webpack_require__)
      module.l = true
      return module.exports
    }
    __webpack_require__.m = modules
    __webpack_require__.c = installedModules
    __webpack_require__.d = function (exports, name, getter) {
      if (!__webpack_require__.o(exports, name)) {
        Object.defineProperty(exports, name, {
          enumerable: true,
          get: getter
        })
      }
    }
    __webpack_require__.r = function (exports) {
      if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
        Object.defineProperty(exports, Symbol.toStringTag, {
          value: 'Module'
        })
      }
      Object.defineProperty(exports, '__esModule', {
        value: true
      })
    }
    __webpack_require__.t = function (value, mode) {
      if (mode & 1) value = __webpack_require__(value)
      if (mode & 8) return value
      if (mode & 4 && typeof value === 'object' && value && value.__esModule) return value
      var ns = Object.create(null)
      __webpack_require__.r(ns)
      Object.defineProperty(ns, 'default', {
        enumerable: true,
        value: value
      })
      if (mode & 2 && typeof value != 'string')
        for (var key in value)
          __webpack_require__.d(
            ns,
            key,
            function (key) {
              return value[key]
            }.bind(null, key)
          )
      return ns
    }
    __webpack_require__.n = function (module) {
      var getter =
        module && module.__esModule
          ? function getDefault() {
              return module['default']
            }
          : function getModuleExports() {
              return module
            }
      __webpack_require__.d(getter, 'a', getter)
      return getter
    }
    __webpack_require__.o = function (object, property) {
      return Object.prototype.hasOwnProperty.call(object, property)
    }
    __webpack_require__.p = ''
    return __webpack_require__((__webpack_require__.s = 4))
  })([
    function (module) {
      module.exports = JSON.parse('["width","height"]')
    },
    function (module) {
      module.exports = JSON.parse('["left","top"]')
    },
    function (module) {
      module.exports = JSON.parse('["x","y"]')
    },
    function (module) {
      module.exports = JSON.parse('["ctrl","shift","alt","meta"]')
    },
    function (module, __webpack_exports__, __webpack_require__) {
      'use strict'
      __webpack_require__.r(__webpack_exports__)
      function isFunction(o) {
        return typeof o === 'function'
      }
      var isFunction_1_0_0 = isFunction
      function callFunction(fn, ...args) {
        if (isFunction_1_0_0(fn)) {
          return fn.call(this, ...args)
        }
      }
      var callFunctioncodehub = callFunction
      function addEventListener(el, ...args) {
        el.addEventListener(...args)
        const disposer = () => {
          if (!disposer.disposed) {
            el.removeEventListener(...args)
            return (disposer.disposed = true)
          }
        }
        disposer.disposed = false
        return disposer
      }
      var addEventListenercodehub = addEventListener
      function addActionEventListener(el, actionType, ...args) {
        const type = (() => {
          const actionSource = (() => {
            for (let __i = 0; __i < ACTION_SOURCES.length; __i++) {
              let key = ACTION_SOURCES[__i]
              if (`on${key}down` in window) {
                return key
              }
            }
          })()
          return `${actionSource}${actionType}`
        })()
        return addEventListenercodehub(el, type, ...args)
      }
      const ACTION_SOURCES = ['pointer', 'touch', 'mouse']
      const ACTION_TYPES = ['down', 'move', 'up', 'cancel']
      Object.assign(addActionEventListener, {
        sources: ACTION_SOURCES,
        types: ACTION_TYPES
      })
      var addActionEventListenercodehub = addActionEventListener
      function addDragableEventListener(el, handler, op = {}) {
        if (!('addEventListener' in el)) {
          op = handler || {}
          handler = el
          el = document
        }
        const { limit: limit = 3 } = op
        const { types: types } = addActionEventListenercodehub
        let lastDownEvent = null,
          dragable = false,
          dragging = false,
          swap = null
        const cancelDragging = (e = lastDownEvent) => {
          if (dragable) {
            dragable = false
            lastDownEvent = null
            if (dragging) {
              callFunctioncodehub(handler.dragend, e, swap)
              dragging = false
              swap = null
            }
          }
        }
        const disposes = (() => {
          const __arr = []
          for (let __i = 0; __i < types.length; __i++) {
            let type = types[__i]
            __arr.push(
              addActionEventListenercodehub(
                el,
                type,
                (e) => {
                  switch (type) {
                    case 'down':
                      cancelDragging(e)
                      if (handler.dragable) {
                        swap = callFunctioncodehub(handler.dragable, e)
                        if (swap) {
                          dragable = true
                        }
                      } else {
                        dragable = true
                      }
                      if (dragable) {
                        lastDownEvent = e
                        if (!swap) {
                          swap = {}
                        }
                      }
                      break

                    case 'move':
                      if (dragable) {
                        if (!dragging) {
                          if (
                            ['x', 'y'].every(
                              (key) => Math.abs(lastDownEvent[key] - e[key]) >= limit
                            )
                          ) {
                            callFunctioncodehub(handler.dragstart, e, swap)
                            dragging = true
                          }
                        }
                        if (dragging) {
                          callFunctioncodehub(handler.drag, e, swap)
                        }
                      }
                      break

                    case 'up':
                    case 'cancel':
                      cancelDragging(e)
                  }
                },
                op
              )
            )
          }
          return __arr
        })()
        return () => {
          cancelDragging()
          disposes.forEach((dispose) => {
            dispose()
          })
        }
      }
      var addDragableEventListenercodehub = addDragableEventListener
      function isPointInRect(p, points) {
        if (!Array.isArray(points)) {
          const rect = points
          points = [
            [rect.left, rect.top],
            [rect.left + rect.width, rect.top + rect.height]
          ]
        }
        for (let i = 0; i < 2; i++) {
          if (p[i] < points[0][i] || p[i] > points[1][i]) {
            return false
          }
        }
        return true
      }
      var isPointInRectcodehub = isPointInRect
      function addDropableEventListener(el, handler, op = {}) {
        if (!('addEventListener' in el)) {
          op = handler
          handler = el
          el = document
        }
        return addDragableEventListenercodehub(
          el,
          {
            ...handler,
            dragstart(e, swap) {
              swap.dropableNode = null
              callFunctioncodehub(handler.dragstart, e, swap)
            },
            drag(e, swap) {
              const point = ['x', 'y'].map((key) => e[key])
              const dropableNode = (() => {
                if (!swap.dropableNodes) {
                  swap.dropableNodes = getHandlerValue(handler, 'dropableNodes', [])
                }
                if (!swap.dropableRects) {
                  swap.dropableRects = swap.dropableNodes.map((node) =>
                    node.getBoundingClientRect()
                  )
                }
                for (let __a = swap.dropableRects, i = 0; i < __a.length; i++) {
                  let rect = __a[i]
                  if (isPointInRectcodehub(point, rect)) {
                    return swap.dropableNodes[i]
                  }
                }
              })()
              if (dropableNode !== swap.dropableNode) {
                if (swap.dropableNode) {
                  callFunctioncodehub(handler.dragleave, e, swap)
                }
                swap.dropableNode = dropableNode
                if (dropableNode) {
                  callFunctioncodehub(handler.dragenter, e, swap)
                }
              }
              if (dropableNode) {
                callFunctioncodehub(handler.dragover, e, swap)
              }
              callFunctioncodehub(handler.drag, e, swap)
            },
            dragend(e, swap) {
              if (swap.dropableNode) {
                callFunctioncodehub(handler.dragleave, e, swap)
              }
              if (swap.dropableNode) {
                callFunctioncodehub(handler.drop, e, swap)
              } else {
                callFunctioncodehub(handler.dropout, e, swap)
              }
              callFunctioncodehub(handler.dragend, e, swap)
            }
          },
          op
        )
      }
      function getHandlerValue(handler, key, defaultValue) {
        let value = handler[key]
        if (isFunction_1_0_0(value)) {
          value = value()
        }
        if (value === undefined) {
          value = defaultValue
        }
        return value
      }
      var addDropableEventListenercodehub = addDropableEventListener
      var WH_KEYScodehub = __webpack_require__(0)
      function toCapitalCase(str) {
        return str.replace(/./, (chr) => chr.toUpperCase())
      }
      var toCapitalCasecodehub = toCapitalCase
      var CLIENT_WH_KEYS_tjson_codehub = WH_KEYScodehub.map(
        (key) => 'client' + toCapitalCasecodehub(key)
      )
      function getNodeClientSize(el) {
        return CLIENT_WH_KEYS_tjson_codehub.map((key) => el[key])
      }
      var getNodeClientSizecodehub = getNodeClientSize
      function isEqualArrays(arrA, arrB) {
        if (arrA.length === arrB.length) {
          return arrA.every((v, i) => v === arrB[i])
        }
        return false
      }
      var isEqualArrayscodehub = isEqualArrays
      function addResizeEventListener(el, listener, op) {
        const getSize = () => getNodeClientSizecodehub(el)
        const size = getSize()
        return addEventListenercodehub(
          window,
          'resize',
          (e) => {
            const currentSize = getSize()
            if (!isEqualArrayscodehub(size, currentSize)) {
              listener(currentSize)
            }
          },
          op
        )
      }
      var addResizeEventListenercodehub = addResizeEventListener
      function addClickEventListener(el, task, op = {}) {
        const {
          types: types = ['down', 'up', 'cancel'],
          limit: limit = 5,
          timeout: timeout = 300,
          button: button = 0
        } = op
        let lastDownEvent = null
        const listener = (type, e) => {
          switch (type) {
            case 'down':
              if (button !== -1) {
                if (button !== e.button) {
                  return
                }
              }
              lastDownEvent = e
              break

            case 'up':
              if (lastDownEvent) {
                if (e.button === lastDownEvent.button) {
                  if (e.timeStamp - lastDownEvent.timeStamp < timeout) {
                    if (['x', 'y'].every((key) => Math.abs(lastDownEvent[key] - e[key]) < limit)) {
                      task(e)
                    }
                  }
                }
                lastDownEvent = null
              }
              break

            case 'cancel':
              lastDownEvent = null
          }
        }
        const disposes = (() => {
          const __arr = []
          for (let __i = 0; __i < types.length; __i++) {
            let type = types[__i]
            __arr.push(addActionEventListenercodehub(el, type, (e) => listener(type, e)))
          }
          return __arr
        })()
        return () => disposes.forEach((dispose) => dispose())
      }
      var addClickEventListenercodehub = addClickEventListener
      function isRectsOverlap(rect, rect2) {
        return !(
          rect2.left >= rect.left + rect.width ||
          rect2.left + rect2.width <= rect.left ||
          rect2.top >= rect.top + rect.height ||
          rect2.top + rect2.height <= rect.top
        )
      }
      var isRectsOverlapcodehub = isRectsOverlap
      var LT_KEYScodehub = __webpack_require__(1)
      var XY_KEYScodehub = __webpack_require__(2)
      class AutoLayoutGridcodehub_AutoLayoutGrid {
        constructor(op) {}
        static moveItem(items, sourceItemId) {
          const newItems = this.sortItems(items)
          const offsetItem = (item, changedItem) => {
            const { height: height = 0, top: top = 0 } = changedItem
            const { top: itemTop = 0 } = item
            return {
              ...item,
              top: Math.max(top + height, itemTop + height)
            }
          }
          let changedItemIds = [sourceItemId]
          while (changedItemIds.length > 0) {
            changedItemIds = (() => {
              const __arr = []
              for (let __i = 0; __i < changedItemIds.length; __i++) {
                let changedItemId = changedItemIds[__i]
                for (let i = 0; i < newItems.length; i++) {
                  let item = newItems[i]
                  if (item.id === changedItemId) {
                    continue
                  }
                  if (
                    isRectsOverlapcodehub(
                      item,
                      newItems.find((item) => item.id === changedItemId)
                    )
                  ) {
                    if (changedItemIds.includes(item.id)) {
                      newItems[i] = offsetItem(
                        item,
                        newItems.find((item) => item.id === changedItemId)
                      )
                      continue
                    }
                    newItems[i] = offsetItem(
                      item,
                      newItems.find((item) => item.id === changedItemId)
                    )
                    __arr.push(item.id)
                  }
                }
              }
              return __arr
            })()
          }
          for (let i = 0; i < newItems.length; i++) {
            let item = newItems[i]
            newItems[i] = this.moveUpIfNeed(newItems, item)
          }
          if (isEqualArrayscodehub(newItems, items)) {
            return items
          }
          return newItems
        }
        static getLoverlapItem(items, sourceItem) {
          for (let i = 0; i < items.length; i++) {
            let item = items[i]
            if (item.id === sourceItem.id) {
              continue
            }
            if (isRectsOverlapcodehub(item, sourceItem)) {
              return item
            }
          }
        }
        static moveUpIfNeed(items, item) {
          const newItem = {
            ...item
          }
          while (true) {
            if (newItem.top > 0) {
              newItem.top--
              let overlapItem = this.getLoverlapItem(items, newItem)
              if (overlapItem && overlapItem.top <= newItem.top) {
                newItem.top++
              } else {
                continue
              }
            }
            break
          }
          if (item.top !== newItem.top) {
            return newItem
          }
          return item
        }
        static sortItems(items) {
          return [...items].sort((a, b) => {
            if (a.top === b.top && a.left === b.left) {
              return 0
            }
            if (a.top > b.top || (a.top === b.top && a.left > b.left)) {
              return 1
            }
            return -1
          })
        }
        static addDragEvents(swap, op) {
          const getNodeRect = (el) => {
            const __obj = {}
            for (
              let __a = [].concat(LT_KEYScodehub, WH_KEYScodehub), __i = 0;
              __i < __a.length;
              __i++
            ) {
              let key = __a[__i]
              let value = el.style[key]
              value = parseFloat(value)
              __obj[key] = value
            }
            return __obj
          }
          return addDragableEventListenercodehub(
            {
              dragable: (e) => {
                const { getInfoFromEvent: getInfoFromEvent, getItemById: getItemById } = swap
                const { id: id, el: el, resizerKeys: resizerKeys } = getInfoFromEvent(e)
                if (!id) {
                  return
                }
                return {
                  dragstartEvent: e,
                  dragableItemId: id,
                  dragableItem: {
                    ...getItemById(id)
                  },
                  dragableNode: el,
                  resizerKeys: resizerKeys,
                  getNodeRect,
                  layouter: this,
                  dragableNodeRect: getNodeRect(el)
                }
              },
              dragstart: (e, dragSwap) => {
                const el = document.createElement('div')
                el.setAttribute('drag-mask', '')
                el.style.cssText = `position:fixed; left: 0; top: 0; width: 100%; height:100%; z-index: 999`
                document.body.append(el)
                dragSwap.dragMask = el
                {
                  const { dragableItemId: dragableItemId, dragableNodeRect: dragableNodeRect } =
                    dragSwap
                  const { setDraggingItem: setDraggingItem } = swap
                  setDraggingItem({
                    id: dragableItemId,
                    style: {
                      ...dragableNodeRect
                    }
                  })
                }
                if (swap.onDragstart) {
                  swap.onDragstart(e, dragSwap, swap)
                }
              },
              dragend: (e, dragSwap) => {
                dragSwap.dragMask.remove()
                {
                  const { setDraggingItem: setDraggingItem } = swap
                  setDraggingItem(null)
                }
                if (dragSwap.resizerKeys) {
                  if (swap.onResized) {
                    swap.onResized(e, dragSwap, swap)
                  }
                } else {
                  if (swap.onMoved) {
                    swap.onMoved(e, dragSwap, swap)
                  }
                }
                if (swap.onDragend) {
                  swap.onDragend(e, dragSwap, swap)
                }
              },
              drag: (e, dragSwap) => {
                if (swap.onDrag) {
                  e = swap.onDrag(e, dragSwap, swap) || e
                }
                if (dragSwap.resizerKeys) {
                  this.onReszieEvent(e, dragSwap, swap)
                } else {
                  this.onMoveEvent(e, dragSwap, swap)
                }
              }
            },
            op
          )
        }
        static runAutoScrollIfNeed(e, dragSwap, swap, dragDirection) {
          if (dragSwap.disposeAutoScroll) {
            return
          }
        }
        static cancelAutoScroll(dragSwap) {
          if (dragSwap.disposeAutoScroll) {
            dragSwap.disposeAutoScroll()
          }
        }
        static onMoveEvent(e, dragSwap, swap) {
          const { dragableItemId: dragableItemId, dragstartEvent: dragstartEvent } = dragSwap
          const dragPoint = XY_KEYScodehub.map((key) => dragstartEvent[key])
          const dragOffset = XY_KEYScodehub.map((key) => e[key] - dragstartEvent[key])
          const {
            items: items,
            setItems: setItems,
            getItemById: getItemById,
            getItemNodeById: getItemNodeById
          } = swap
          const dragableItem = getItemById(dragableItemId)
          if (!dragSwap.lastDragableItem) {
            dragSwap.lastDragableItem = {
              ...dragableItem
            }
          }
          const lastDragableItem = dragSwap.lastDragableItem
          const dragDirection = (() => {
            const lastEvent = dragSwap.lastEvent || dragstartEvent
            dragSwap.lastEvent = e
            return e.y - lastEvent.y > 0 ? 1 : -1
          })()
          {
            const { dragableNodeRect: dragableNodeRect } = dragSwap
            const { setDraggingItem: setDraggingItem } = swap
            setDraggingItem((item) => ({
              ...item,
              style: {
                ...item.style,
                left: dragableNodeRect.left + dragOffset[0],
                top: dragableNodeRect.top + dragOffset[1]
              }
            }))
          }
          const offsetCols = (() => {
            const { colWidth: colWidth, gridCols: gridCols } = swap
            const dragCols = Math.round(dragOffset[0] / colWidth)
            if (dragCols + lastDragableItem.left < 0) {
              return 0 - lastDragableItem.left
            }
            if (dragCols + lastDragableItem.left + lastDragableItem.width > gridCols) {
              return gridCols - lastDragableItem.left - lastDragableItem.width
            }
            return dragCols
          })()
          const offsetRows = (() => {
            const { rowHeight: rowHeight } = swap
            const dragRows = Math.round(dragOffset[1] / rowHeight)
            if (dragRows + lastDragableItem.top < 0) {
              return 0 - lastDragableItem.top
            }
            return dragRows
          })()
          let newItems = AutoLayoutGridcodehub_AutoLayoutGrid.sortItems(items)
          const sourceIndex = newItems.findIndex((t) => t.id === dragableItemId)
          newItems[sourceIndex] = {
            ...newItems[sourceIndex],
            left: lastDragableItem.left + offsetCols,
            top: lastDragableItem.top + offsetRows
          }
          const sourceItem = newItems[sourceIndex]
          const targetItem = (() =>
            AutoLayoutGridcodehub_AutoLayoutGrid.getLoverlapItem(items, sourceItem))()
          const isNewTargetItem = (() => {
            var _dragSwap$lastTargetI
            if (
              ((_dragSwap$lastTargetI = dragSwap.lastTargetItem) === null ||
              _dragSwap$lastTargetI === void 0
                ? void 0
                : _dragSwap$lastTargetI.id) !==
              (targetItem === null || targetItem === void 0 ? void 0 : targetItem.id)
            ) {
              dragSwap.lastTargetItem = targetItem
              return true
            }
          })()
          const targetNode = (() => {
            if (isNewTargetItem) {
              dragSwap.lastTargetNode = targetItem && getItemNodeById(targetItem.id)
            }
            return dragSwap.lastTargetNode
          })()
          const action = (() => {
            if (targetNode) {
              const rect = dragSwap.getNodeRect(targetNode)
              if (e.y > rect.top && e.y < rect.top + 50) {
                return dragDirection > 0 ? 'after' : 'before'
              }
            }
            return 'move'
          })()
          if (action) {
            switch (action) {
              case 'before':
                newItems[sourceIndex] = {
                  ...sourceItem,
                  top: targetItem.top
                }
                break

              case 'after':
                newItems[sourceIndex] = {
                  ...dragableItem,
                  top: targetItem.top + targetItem.height
                }
                break

              case 'insert':
                break

              case 'move':
                newItems[sourceIndex] = {
                  ...dragableItem,
                  left: lastDragableItem.left + offsetCols
                }
            }
            newItems = AutoLayoutGridcodehub_AutoLayoutGrid.moveItem(newItems, dragableItemId)
            setItems(newItems)
          }
        }
        static onReszieEvent(e, dragSwap, swap) {
          const {
            dragableItemId: dragableItemId,
            resizerKeys: resizerKeys,
            dragstartEvent: dragstartEvent,
            dragableItem: dragableItem,
            dragableNodeRect: dragableNodeRect
          } = dragSwap
          const {
            rowHeight: rowHeight,
            colWidth: colWidth,
            gridCols: gridCols,
            setDraggingItem: setDraggingItem,
            items: items,
            setItems: setItems,
            getItemById: getItemById,
            minRowHeight: defaultMinHeight = 1,
            minColWidth: defaultMinWidth = 1
          } = swap
          const { minHeight: minHeight = defaultMinHeight, minWidth: minWidth = defaultMinWidth } =
            getItemById(dragableItemId)
          const dragPoint = XY_KEYScodehub.map((key) => dragstartEvent[key])
          const dragOffset = XY_KEYScodehub.map((key) => e[key] - dragstartEvent[key])
          const dragCells = [colWidth, rowHeight].map((v, i) => Math.round(dragOffset[i] / v))
          const offsetRect = {}
          const offsetItem = {}
          for (let __i = 0; __i < resizerKeys.length; __i++) {
            let resizerKey = resizerKeys[__i]
            switch (resizerKey) {
              case 'left': {
                const offsetCell = Math.max(
                  -dragableItem.left,
                  Math.min(dragableItem.width - minWidth, dragCells[0])
                )
                offsetItem.left = dragableItem.left + offsetCell
                offsetItem.width = dragableItem.width - offsetCell
                offsetRect.left = dragableNodeRect.left + dragOffset[0]
                offsetRect.width = dragableNodeRect.width - dragOffset[0]
                break
              }

              case 'right': {
                const offsetCell = Math.max(
                  -(dragableItem.width - minWidth),
                  Math.min(gridCols - dragableItem.width - dragableItem.left, dragCells[0])
                )
                offsetItem.width = dragableItem.width + offsetCell
                offsetRect.width = dragableNodeRect.width + dragOffset[0]
                break
              }

              case 'bottom': {
                const offsetCell = Math.max(
                  -(dragableItem.height - minHeight),
                  Math.min(100, dragCells[1])
                )
                offsetItem.height = dragableItem.height + offsetCell
                offsetRect.height = dragableNodeRect.height + dragOffset[1]
              }
            }
          }
          setDraggingItem((item) => ({
            ...item,
            style: {
              ...item.style,
              ...offsetRect
            }
          }))
          let newItems = [...items]
          const sourceIndex = newItems.findIndex((t) => t.id === dragableItemId)
          newItems[sourceIndex] = {
            ...newItems[sourceIndex],
            ...offsetItem
          }
          newItems = this.moveItem(newItems, dragableItemId)
          setItems(newItems)
        }
      }
      var AutoLayoutGridcodehub = AutoLayoutGridcodehub_AutoLayoutGrid
      class CursorStack {
        constructor(limit = 30, onChange) {
          Object.assign(this, {
            stack: [],
            _index: -1,
            limit: limit,
            onChange: onChange
          })
        }
        entries() {
          return this.stack
        }
        get size() {
          return this.stack.length
        }
        get index() {
          return this._index
        }
        set index(index) {
          if (index >= 0 && index < this.size) {
            this._index = index | 0
            if (this.onChange) {
              this.onChange(this.value)
            }
          }
        }
        get value() {
          return this.stack[this.index]
        }
        push(value) {
          if (this.index !== this.size - 1) {
            this.stack.splice(this.index + 1)
          }
          this.stack.push(value)
          if (this.size > this.limit) {
            this.stack.splice(0, this.size - this.limit)
            this.index = this.size - 1
          } else {
            this.index++
          }
        }
        get prevLength() {
          return this.index
        }
        get nextLength() {
          return this.size === 0 ? 0 : this.index
        }
        prev() {
          --this.index
        }
        next() {
          ++this.index
        }
      }
      var CursorStackcodehub = CursorStack
      class StateHistorycodehub_StateHistory extends CursorStackcodehub {
        constructor(limit) {
          const onChange = ({ state: state }) => {
            this.stack = this.stack.slice(0)
            this._broadcast(state)
          }
          super(limit, onChange)
          this._listeners = new Set()
        }
        get state() {
          const { state: state } = this.value || {}
          return state
        }
        set state(state) {
          if (this.value) {
            this.value.state = state
          }
        }
        push(state, label = '') {
          const id = Date.now() + Math.random()
          super.push({
            state: state,
            label: label,
            id: id
          })
        }
        subscribe(task) {
          const { _listeners: listenerSet } = this
          listenerSet.add(task)
          return () => {
            listenerSet.delete(task)
          }
        }
        _broadcast(state) {
          const { _listeners: listenerSet } = this
          listenerSet.forEach((task) => task(state))
        }
      }
      var StateHistorycodehub = StateHistorycodehub_StateHistory
      var keyboardHelperKeyscodehub = __webpack_require__(3)
      function parseShortcutStringToKeys(str, sep = '+') {
        const helperKeys = []
        const keys = []
        const originKeys = str.split(sep).map((key) => key.trim())
        const matchKeys = Array.from(new Set(originKeys))
        for (let i = 0; i < matchKeys.length; i++) {
          let key = matchKeys[i]
          if (key === '') {
            if (i === 0 || i === matchKeys.length - 1) {
              continue
            }
            key = sep
          }
          if (keyboardHelperKeyscodehub.includes(key)) {
            helperKeys.push(key)
          } else {
            keys.push(key)
          }
        }
        return [helperKeys, keys]
      }
      var parseShortcutStringToKeyscodehub = parseShortcutStringToKeys
      function parseShortcutStringToObject(str, op = {}) {
        const { sep: sep = '+', strict: strict = true } = op
        const [helperKeys, keys] = parseShortcutStringToKeyscodehub(str, sep)
        const obj = {}
        if (strict) {
          for (let i = 0; i < keyboardHelperKeyscodehub.length; i++) {
            let key = keyboardHelperKeyscodehub[i]
            const targetKey = keyboardHelperTargetKeys[i]
            obj[targetKey] = helperKeys.includes(key)
          }
        } else {
          for (let __i = 0; __i < helperKeys.length; __i++) {
            let key = helperKeys[__i]
            const i = keyboardHelperKeyscodehub.indexOf(key)
            const targetKey = keyboardHelperTargetKeys[i]
            obj[targetKey] = true
          }
        }
        if (keys.length) {
          obj.key = keys[0]
        }
        return obj
      }
      const keyboardHelperTargetKeys = keyboardHelperKeyscodehub.map((key) => key + 'Key')
      var parseShortcutStringToObjectcodehub = parseShortcutStringToObject
      function isEventMatchShortcutObject(e, obj, op = {}) {
        for (let __a = Object.keys(obj), __i = 0; __i < __a.length; __i++) {
          let key = __a[__i],
            value = obj[key]
          let eValue = e[key]
          if (key === 'targetKey') {
            eValue = eValue.toLowerCase()
          }
          if (value !== eValue) {
            return false
          }
        }
        return true
      }
      var isEventMatchShortcutObjectcodehub = isEventMatchShortcutObject
      function isInputNode(node) {
        return (
          ['INPUT', 'TEXTAREA'].includes(node.tagName) &&
          !['checkbox', 'radio', 'range'].includes(node.type)
        )
      }
      var isInputNode_1_0_0 = isInputNode
      function isInputableNode(node) {
        return (
          (isInputNode_1_0_0(node) && !node.disabled && !node.readonly) || node.isContentEditable
        )
      }
      var isInputableNode_1_0_0 = isInputableNode
      function isInputable() {
        return isInputableNode_1_0_0(document.activeElement)
      }
      var isInputable_1_0_0 = isInputable
      class ShortcutEmittercodehub_ShortcutEmitter {
        constructor() {
          this._shortcuts = []
        }
        _parseShortcutKey(shortcutKey) {
          return shortcutKey.toLowerCase().replace(/\s+/g, '')
        }
        has(shortcutKey, task) {
          shortcutKey = this._parseShortcutKey(shortcutKey)
          return this._shortcuts.some((conf) => conf.shortcutKey === shortcutKey)
        }
        add(shortcutKey, task, option = {}) {
          shortcutKey = this._parseShortcutKey(shortcutKey)
          const { prevent: prevent = true, inputable: inputable = false, ...attrs } = option
          const info = parseShortcutStringToObjectcodehub(shortcutKey)
          info.targetKey = info.key
          delete info.key
          const config = {
            shortcutKey: shortcutKey,
            inputable: inputable,
            prevent: prevent,
            info: info,
            task: task,
            ...attrs
          }
          this._shortcuts.push(config)
          return config
        }
        remove(shortcutKey) {
          shortcutKey = this._parseShortcutKey(shortcutKey)
          const i = this._shortcuts.findIndex((conf) => conf.shortcutKey === shortcutKey)
          if (i !== -1) {
            this._shortcuts.splice(i, 1)
            return true
          }
        }
        _emitKeyboardEvent(e) {
          e.targetKey = this._parseShortcutKey(e.key)
          for (let __a = this._shortcuts, __i = 0; __i < __a.length; __i++) {
            let config = __a[__i]
            const { info: info, task: task, prevent: prevent, inputable: inputable } = config
            if (isEventMatchShortcutObjectcodehub(e, info)) {
              if (!inputable) {
                if (isInputable_1_0_0()) {
                  break
                }
              }
              if (prevent) {
                e.preventDefault()
              }
              if (this.onemit) {
                this.onemit(e, config)
              }
              const rs = task(e, config)
              if (rs === false) {
                break
              }
            }
          }
        }
        dispose() {
          this._shortcuts.splice(0)
        }
      }
      var ShortcutEmittercodehub = ShortcutEmittercodehub_ShortcutEmitter
      class ShortcutsEmittercodehub_ShortcutsEmitter extends ShortcutEmittercodehub {
        constructor() {
          super()
          this._interval = 360
          this._shadowEmiteds = {}
          this._shadowTask = (e, { shortcutKey: shortcutKey }) => {
            this._shadowEmiteds[shortcutKey] = e.timeStamp
          }
        }
        _splitShortcutKey(shortcutKey) {
          return shortcutKey.split(/\b\s+\b/).map(this._parseShortcutKey)
        }
        add(shortcutKey, task, option = {}) {
          const shortcutKeys = this._splitShortcutKey(shortcutKey)
          if (shortcutKeys.length === 1) {
            return super.add(shortcutKey, task)
          } else {
            const _task = (e, config) => {
              const { deps: deps, userTask: userTask } = config
              const timeStamps = deps.map((shortcutKey) => this._shadowEmiteds[shortcutKey] || 0)
              timeStamps.push(e.timeStamp)
              for (let i = 1; i < timeStamps.length; i++) {
                let timeStamp = timeStamps[i]
                const dur = timeStamp - timeStamps[i - 1]
                if (dur < 0 || dur > this._interval) {
                  return
                }
              }
              return userTask(e, config)
            }
            const config = (() => {
              for (let i = 0; i < shortcutKeys.length; i++) {
                let shortcutKey = shortcutKeys[i]
                if (i === shortcutKeys.length - 1) {
                  return super.add(shortcutKey, _task)
                } else {
                  const hasShadow = this._shortcuts.some(
                    (config) => config.shortcutKey === shortcutKey && config.shadow
                  )
                  if (!hasShadow) {
                    super.add(shortcutKey, this._shadowTask, {
                      shadow: true
                    })
                  }
                }
              }
            })()
            Object.assign(config, {
              deps: shortcutKeys.slice(0, -1),
              userTask: task,
              key: shortcutKeys.join(' ')
            })
            return config
          }
        }
        dispose() {
          super.dispose()
          this._emiteds = {}
        }
      }
      var ShortcutsEmittercodehub = ShortcutsEmittercodehub_ShortcutsEmitter
      class Shortcutscodehub_Shortcuts extends ShortcutsEmittercodehub {
        constructor() {
          super()
          this._mounteds = []
          this._mount(document)
        }
        _mount(el) {
          if (!this._mounteds.some((op) => op.element === el)) {
            const op = {
              element: el,
              disposer: addEventListenercodehub(el, 'keydown', (e) => this._emitKeyboardEvent(e))
            }
            this._mounteds.push(op)
            return true
          }
        }
        _unmount(el) {
          const i = this._mounteds.findIndex((op) => op.element === el)
          if (i !== -1) {
            const [{ disposer: disposer }] = this._mounteds.splice(i, 1)
            disposer()
            return true
          }
        }
        dispose() {
          super.dispose()
          for (let __a = this._mounteds, __i = 0; __i < __a.length; __i++) {
            let { disposer: disposer } = __a[__i]
            disposer()
          }
        }
      }
      var Shortcutscodehub = Shortcutscodehub_Shortcuts
      function emitUrlDownload(url, filename) {
        const a = document.createElement('a')
        a.href = url
        a.download = filename
        a.click()
      }
      var emitUrlDownloadcodehub = emitUrlDownload
      function emitDataUrlDownload(dataUrl, filename) {
        const url = dataUrl.replace(/\/.+;/, '/octet-stream;')
        emitUrlDownloadcodehub(url, filename)
      }
      var emitDataUrlDownloadcodehub = emitDataUrlDownload
      function emitBlobDownload(blob, filename) {
        const url = URL.createObjectURL(blob)
        emitUrlDownloadcodehub(url, filename)
      }
      var emitBlobDownloadcodehub = emitBlobDownload
      function emitDownload(content, filename) {
        if (content == null) {
          content = ''
        }
        if (content.constructor !== Blob) {
          content = new Blob([content])
        }
        emitBlobDownloadcodehub(content, filename)
      }
      var emitDownloadcodehub = emitDownload
      var UTF8_BOM_tjson_codehub = String.fromCharCode(65279)
      function encodeCsvCell(content, sep = ',', delimiter = '\n', forceWrap = false) {
        if (content != null) {
          content = content + ''
          const hasQuoted = content.includes('"')
          const needWrapQuoted =
            forceWrap || hasQuoted || [sep, delimiter].some((char) => content.includes(char))
          if (needWrapQuoted) {
            if (hasQuoted) {
              content = content.replace(/"/g, '""')
            }
            content = `"${content}"`
          }
        } else {
          content = ''
        }
        return content
      }
      var encodeCsvCellcodehub = encodeCsvCell
      function tableArray2csv(tableArray, op = {}) {
        const { sep: sep = ',', delimiter: delimiter = '\n', forceWrap: forceWrap = false } = op
        const array = []
        for (let rowIndex = 0; rowIndex < tableArray.length; rowIndex++) {
          let row = tableArray[rowIndex]
          if (rowIndex === 0) {
            array.push(UTF8_BOM_tjson_codehub)
          }
          for (let cellIndex = 0; cellIndex < row.length; cellIndex++) {
            let cell = row[cellIndex]
            if (cellIndex !== 0) {
              array.push(sep)
            }
            cell = encodeCsvCellcodehub(cell, sep, delimiter, forceWrap)
            array.push(cell)
          }
          array.push(delimiter)
        }
        return array.join('')
      }
      var tableArray2csvcodehub = tableArray2csv
      const kit = {
        addDragableEventListener: addDragableEventListenercodehub,
        addDropableEventListener: addDropableEventListenercodehub,
        addResizeEventListener: addResizeEventListenercodehub,
        addClickEventListener: addClickEventListenercodehub,
        AutoLayoutGrid: AutoLayoutGridcodehub,
        StateHistory: StateHistorycodehub,
        Shortcuts: Shortcutscodehub,
        emitDataUrlDownload: emitDataUrlDownloadcodehub,
        emitDownload: emitDownloadcodehub,
        tableArray2csv: tableArray2csvcodehub
      }
      var src = (__webpack_exports__['default'] = kit)
    }
  ])['default']
})
